import dayjs from 'dayjs'

// 按日期类型分组
export const transDateList = (arr, formatType) => {
  return arr.reduce((group, obj) => {
    const key = dayjs(obj.date).format(formatType)
    group[key] = group[key] ?? []
    group[key].push(obj)
    return group
  }, {})
}

export const getMoenyCount = (arr, type) => {
  const money = arr.filter(item => item.type === type).reduce((acc, cur) => {
    return acc + cur.money
  }, 0)
  return money
}
